var app = getApp();
// pages/filterElementChange/filterElementChange.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    eq_num: '',
    page: 1,
    pageSize: 10,
    listLog: [],
    eq_info: [],
    loadShow:true,
    is_load:false
  },


  

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      eq_num: options.eq_sn
    });
    
  },
  onShow(){
    this.setData({
      listLog: [],
      eq_info: [],
      loadShow:true,
      is_load:false,
    })
    this.changLog();
    this.getEq();
  },
  changLog() {
    var that = this;
    if (that.data.eq_num == '') {
      app.showToast('请输入设备号');
      return false;
    }

    app.ajax({
      url: "Manage/Equipment/changLog",
      data: {
        sn: that.data.eq_num,
        page: that.data.page,
        row: that.data.pageSize,
      },
      success: function (res) {
        if (res.data.code == 200) {
          var log = that.data.listLog;
          res.data.data.forEach(function (v, k) {
            log.push(v);
          })
          that.setData({
            listLog: log
          })
        }
        that.setData({
          loadShow:false,
          is_load: true,
        })
      }

    })
  },
  getEq() {
    var that = this;
    if (that.data.eq_num == '') {
      app.showToast('请输入设备号');
      return false;
    }
    app.ajax({
      url: "Manage/Equipment/get_equipment",
      data: {
        eq_sn: that.data.eq_num,
      },
      success: function (res) {
        if (res.data.code == 200) {
          that.setData({
            eq_info: res.data.data
          })
        }
      }

    })
  },

  // 添加记录
  addFilterChange: function () {
    wx.navigateTo({
      url: '../addFilterCore/addFilterCore?eq_sn=' + this.data.eq_num,
    })
  },
})